<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <input id="btn" type="button" value="按钮">
</body>
<script>
    var btn = document.getElementById('btn')
    btn.addEventListener('click',handleClickBtn)
    function handleClickBtn() {
      try{
        alert('点击了按钮')
      }
      catch {
       console.log('出错了')
      }
    }
</script>
</html>